<input type="hidden" id="change_settings_status" value="<?php echo $this->session->flashdata('change_settings_status'); ?>" />
<script type="text/javascript">
  $(document).ready(function() {
	var change_settings_status = $.trim($('#change_settings_status').val());
	if (change_settings_status == 1) {
	  toastr.success('Successfully updated your settings !');
	  return false;
	}
	if (change_settings_status == 2) {
	  toastr.error('No changes made !');
	  return false;
	}
  });
</script>

<div class="page" style="min-height: 500px;">
  <div class="page-container">
    <div class="container">
      <div class="row">
        <div class="span3">
          <h4>Settings</h4>
          <div class="sidebar">
            <ul class="col-nav span3">
              <li><a href="<?php echo base_url('settings/profile'); ?>"><i class="pull-right"></i>Profile</a></li>
              <li><a href="<?php echo base_url('settings/photo'); ?>"><i class="pull-right"></i>Photo</a></li>
              <li><a href="<?php echo base_url('settings/password'); ?>"><i class="pull-right"></i>Password</a></li>
              <li style="background-color: #EEE; outline: solid #CCC 1px;"><a href="<?php echo base_url('settings/others'); ?>"><i class="pull-right"></i>Others</a></li>
            </ul>
          </div>
        </div>
        <div class="span9">

		  <h4 class="header">Change other settings</h4>

          <form class="form-horizontal" method="post" action="<?php echo base_url('settings/others'); ?>">
            <input type="hidden" name="csrf_token" value="<?php echo set_csrf_token(); ?>"/>

			<!-- TWEETBUDDY START -->
            <div class="control-group" style="display: none;">
			  <h6>Notification</h6>
              <label class="control-label">tweetBuddy</label>
              <div class="controls">
                <input title="Enable or Disable tweetBuddy Notifications" value="1" style="margin-top: 8px;" name="user_notification" type="checkbox" <?php if ($user_data['user_notification'] == 1) { ?> checked="checked" <?php } ?>/>
				<?php if ($user_data['user_notification'] == 1) { ?>
  				&nbsp;<span style="position: absolute; color: yellowgreen; margin-top: 5px;">Enabled</span>
				<?php } else { ?>
  				&nbsp;<span style="position: absolute; color: tomato; margin-top: 5px;">Disabled</span>
				<?php } ?>
				<a class="pull-right" onclick="show_hide('set_up_tweet_buddy')" style="text-decoration: none; cursor: pointer; font-style: italic;" title="See how to setup tweetBuddy">[ Setup TweetBuddy ]</a>
                <div id="set_up_tweet_buddy" class="widget" style="margin-top: 10px; display: none;">
                  # Set your home email id (Gmail) in edit profile.<br/>
                  # Add <b>innotweets@gmail.com</b> in your home email chat contacts.<br/>
                  # Inform admin to accept your chat request.
                </div>
              </div>
			  <div class="header"></div>
            </div>
			<!-- TWEETBUDDY END -->

			<!-- USER ONLINE MODE START -->
            <div class="control-group" style="display: none;">
			  <h6>Visibility</h6>
              <label class="control-label">Online / Offline</label>
              <div class="controls">
                <input title="Browse in Online mode or Offline mode" value="1" style="margin-top: 8px;" name="user_online_mode" type="checkbox" <?php if ($user_data['user_online_mode'] == 1) { ?> checked="checked" <?php } ?>/>
				<?php if ($user_data['user_online_mode'] == 1) { ?>
  				&nbsp;<span style="position: absolute; color: yellowgreen; margin-top: 5px;">Online Mode</span>
				<?php } else { ?>
  				&nbsp;<span style="position: absolute; color: tomato; margin-top: 5px;">Offline Mode</span>
				<?php } ?>
              </div>
			  <div class="header"></div>
            </div>
			<!-- USER ONLINE MODE END -->

            <div class="control-group" style="display: none;">
              <div class="controls">
                <button type="submit" class="btn">Save Changes</button>
              </div>
            </div>
          </form>

		  <div>
			<h6>Apps</h6>
			<?php if (!empty($api_apps)) { ?>
  			<table class="table table-striped table-bordered">
  			  <thead>
  				<tr>
  				  <th width="10">Sl.no</th>
  				  <th width="70">App Name</th>
  				  <th width="20">Action</th>
  				</tr>
  			  </thead>
  			  <tbody>
				  <?php $count = 1; ?>
				  <?php foreach ($api_apps as $api_app) { ?>
					<tr>
					  <td><?php echo $count; ?></td>
					  <td><?php echo $api_app['app_name']; ?></td>
					  <td>
						<a title="Unauthorize App" style="text-decoration: none; color: tomato; cursor: pointer;" onclick="return confirm_action('Unauthorize App ?');" href="<?php echo site_url('settings/un_authorize_app/' . $api_app['app_id']); ?>"><i class="icon-large icon-trash"></i></a>
					  </td>
					</tr>
					<?php $count++; ?>
				  <?php } ?>
  			  </tbody>
  			</table>
			<?php } else { ?>
  			<div class="alert alert-error">You dont have any authorized apps !</div>
			<?php } ?>
		  </div>



		  <div class="control-group">
			<h6>Developer</h6>
			<div class="controls">
			  <a class="btn btn-primary" href="<?php echo site_url('extras/api.zip'); ?>">Download SDK</a>
			  <a class="pull-right" onclick="show_hide('set_up_api_apps')" style="text-decoration: none; cursor: pointer; font-style: italic;" title="Developers, See how to use api apps">[ Developer Guide ]</a>

			  <!-- API DOC START -->
			  <div id="set_up_api_apps" class="widget" style="margin-top: 10px; display: none;">
				# Contact admin to create an API App.<br/>
				<div class="clearfix" style="height: 10px;"></div>
				# Get your app token (eg : <b>d0970714757783e6cf17b26fb8e2298f</b>).<br/>
				<div class="clearfix" style="height: 10px;"></div>
				# Prepare request params & generate api token<br/>
				<div class="clearfix" style="height: 10px;"></div>
				<div style="background: #ffffff; overflow:auto; width:auto; border:solid gray; border-width:.1em .1em .1em .8em; padding:.2em .6em;">
				  <pre style="margin: 0; line-height: 125%"> 
<b>// Create the params in JSON format &amp; base64 Encode it.</b><br/>
$req_data = array();
$req_data[&#39;app_token&#39;] = &#39;a87eb8c8dfcc75eae3bbbb7797f91f47&#39;;
$req_data[&#39;app_callback&#39;] = &#39;http://mysite.com/callback_url.php&#39;;
$req_token = @base64_encode(json_encode($req_data));

<br/><br/><b>// Sample JSON</b><br/>
{"app_token":"a87eb8c8dfcc75eae3bbbb7797f91f47","app_callback":"http:\/\/mysite.com\/callback_url.php"}

<br/><br/><b>// base64 Encoded (Your Request Token (req_token))</b><br/>
eyJhcHBfdG9rZW4iOiJhODdlYjhjOGRmY2M3NWVhZTNiYmJiNzc5N2Y5MWY0NyIsImFwcF9jYWxsYmFjayI6Imh0dHA6XC9cL215c2l0ZS5jb21cL2NhbGxiYWNrX3VybC5waHAifQ
				  </pre>
				</div>
				<div class="clearfix" style="height: 10px;"></div>
				# Do a get request (CURL, FILE_GET_CONTENTS, etc..) with your request token (<b>/api/get_token?req_token=</b>) to get your API token
				<div class="clearfix" style="height: 10px;"></div>
				<div style="background: #ffffff; overflow:auto; width:auto; border:solid gray; border-width:.1em .1em .1em .8em; padding:.2em .6em;">
				  <pre style="margin: 0; line-height: 125%"> 
$url = &quot;<?php echo site_url(); ?>api/get_token?req_token=&quot; . $req_token;
$api_token = file_get_contents($url);
				  </pre>
				</div>
				<div class="clearfix" style="height: 10px;"></div>
				# Redirect user to innoTweets with your API token (<b>/api/get_auth?api_token=</b>)
				<div class="clearfix" style="height: 10px;"></div>
				<div style="background: #ffffff; overflow:auto; width:auto; border:solid gray; border-width:.1em .1em .1em .8em; padding:.2em .6em;">
				  <pre style="margin: 0; line-height: 125%"> 
<span>
$auth_url = &#39;<?php echo site_url(); ?>api/get_auth?api_token=&#39; . $api_token;
header(&#39;LOCATION: &#39; . $auth_url);
</span>
				  </pre>
				</div>
				<div class="clearfix" style="height: 10px;"></div>
				# If user authorized your App, Then he will redirect back to your callback url, with an additional param (user_token).<br/>
				<div class="clearfix" style="height: 10px;"></div>
				# Do a get request (CURL, FILE_GET_CONTENTS, etc..) with user token (<b>/api/get_data?user_token=</b>) to get user details.<br/>
				<div class="clearfix" style="height: 10px;"></div>
				<div style="background: #ffffff; overflow:auto; width:auto; border:solid gray; border-width:.1em .1em .1em .8em; padding:.2em .6em;">
				  <pre style="margin: 0; line-height: 125%"> 
$user_token = $_GET[&#39;user_token&#39;];
$url = &quot;<?php echo site_url(); ?>api/get_data?user_token=&quot; . $user_token;
echo $user_data = file_get_contents($url);
				  </pre>
				</div>
				<div class="clearfix" style="height: 10px;"></div>
				# You will get the details of authorized user in JSON format.<br/>
				<div class="clearfix" style="height: 10px;"></div>
				# You can keep the user token and grab the user details any time by calling the (<b>/api/get_data?user_token=</b>) API untill user unauthorize your app.<br/>
				<div class="clearfix" style="height: 10px;"></div>
				# Sample response
				<div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;">
				  <pre style="margin: 0; line-height: 125%">
{<span style="color: #008000; font-weight: bold">&quot;status&quot;</span>:<span style="color: #666666">1</span>,<span style="color: #008000; font-weight: bold">&quot;msg&quot;</span>:<span style="color: #BA2121">&quot;success&quot;</span>,<span style="color: #008000; font-weight: bold">&quot;data&quot;</span>:{<span style="color: #008000; font-weight: bold">&quot;user_id&quot;</span>:<span style="color: #BA2121">&quot;1&quot;</span>,<span style="color: #008000; font-weight: bold">&quot;user_name&quot;</span>:<span style="color: #BA2121">&quot;dinobabu&quot;</span>,<span style="color: #008000; font-weight: bold">&quot;user_display_name&quot;</span>:<span style="color: #BA2121">&quot;Dino&quot;</span>,<span style="color: #008000; font-weight: bold">&quot;user_likes_level&quot;</span>:<span style="color: #BA2121">&quot;19&quot;</span>,<span style="color: #008000; font-weight: bold">&quot;user_gender&quot;</span>:<span style="color: #BA2121">&quot;Male&quot;</span>,<span style="color: #008000; font-weight: bold">&quot;user_position&quot;</span>:<span style="color: #BA2121">&quot;Junior Software Engineer&quot;</span>,<span style="color: #008000; font-weight: bold">&quot;user_skills&quot;</span>:<span style="color: #BA2121">&quot;PHP, Codeigniter, Javascript, MySQL&quot;</span>,<span style="color: #008000; font-weight: bold">&quot;user_hobbies&quot;</span>:<span style="color: #BA2121">&quot;Music, Gaming, Movies, Technology&quot;</span>,<span style="color: #008000; font-weight: bold">&quot;user_place&quot;</span>:<span style="color: #BA2121">&quot;Ankamaly, Ernakulam, Kerala&quot;</span>,<span style="color: #008000; font-weight: bold">&quot;user_online&quot;</span>:<span style="color: #666666">0</span>,<span style="color: #008000; font-weight: bold">&quot;user_image&quot;</span>:<span style="color: #BA2121">&quot;http:\/\/192.168.1.124\/www\/innoTweets\/assets\/photos\/bbf94b34eb32268ada57a3be5062fe7d.jpg&quot;</span>}}
				  </pre>
				</div>
			  </div>
			  <!-- API DOC END -->

			</div>
		  </div>
        </div>
      </div>
    </div>
  </div>
</div>